package cn.dengta.webapp.trade.vo;

import javax.annotation.Nullable;

import cn.dengta.common.model.APIResponse.Field;
import cn.dengta.common.model.Status;
import cn.dengta.webapp.base.entity.I18nContent;
import cn.dengta.webapp.base.vo.AbstractVO;
import cn.dengta.webapp.trade.entity.GiftCategory;
import cn.dengta.webapp.user.model.Gender;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.X;

/**
 * 礼物
 */
@Setter
@Getter
public class GiftCategoryVO extends AbstractVO<GiftCategory> {

	/** 名称 */
	@Field(name = "名称")
	private Object name;
	/** 1:虚拟礼物 2：实体礼物 */
	@Field(name = "类型", value = "1:虚拟礼物；2：实体礼物")
	private Integer type;
	/** 性别 {@link Gender} */
	@Field(name = "性别", value = "0:女；1：男")
	private Gender gender;
	/** 排序 */
	@Field(name = "排序")
	private Integer sort;
	@Field(name = "状态", value = "0=停用；1=启用")
	protected Integer status;

	public static GiftCategoryVO from(@Nullable GiftCategory source) {
		GiftCategoryVO vo = copy(source, GiftCategoryVO::new);
		if (vo != null) {
			vo.name = X.map(source.getResolvedLanguageCfg(), I18nContent::getDataMap);
		}
		return vo;
	}

	public String getType_() {
		return X.map(GiftCategory.GiftCategoryType.of(type), GiftCategory.GiftCategoryType::getLabel);
	}

	public Integer getGender() {
		return X.map(gender, Gender::getValue);
	}

	public String getGender_() {
		return X.map(gender, Gender::getLabel);
	}

	public String getStatus_() {
		return X.map(status, s -> Status.of(s).getToggleLabel());
	}

}
